package com.youwu.weather.controller;

import com.youwu.weather.service.WeatherDataService;
import com.youwu.weather.vo.WeatherResponse;
import com.youwu.weather.vo.WeatherType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Weather Controller.
 */
@RestController
@RequestMapping("/weather")
public class WeatherController {
	@Autowired
	private WeatherDataService weatherDataService;
	
	@GetMapping("/now/{city}")
	@ResponseBody
	public WeatherResponse getCurrentWeather(@PathVariable("city") String cityName) {
		return weatherDataService.getDataByCityName(WeatherType.NOW, cityName);
	}

	@GetMapping("/forecast/{city}")
	@ResponseBody
	public WeatherResponse getForecastWeather(@PathVariable("city") String cityName) {
		return weatherDataService.getDataByCityName(WeatherType.FORECAST, cityName);
	}

	@GetMapping("/hourly/{city}")
	@ResponseBody
	public WeatherResponse getHourlyWeather(@PathVariable("city") String cityName) {
		return weatherDataService.getDataByCityName(WeatherType.HOURLY, cityName);
	}

	@GetMapping("/lifestyle/{city}")
	@ResponseBody
	public WeatherResponse getLifestyleWeather(@PathVariable("city") String cityName) {
		return weatherDataService.getDataByCityName(WeatherType.LIFESTYLE, cityName);
	}
}
